{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "xYITU-6R0jHI"
   },
   "source": [
    "# Food Recommendation System\n",
    "\n",
    "## Overview\n",
    "\n",
    "This project is a vector-based food recommendation system utilizing LanceDB for full-text search (FTS), hybrid search, and vector search. It integrates the  reranker model to enhance search results and provide accurate food recommendations.\n",
    "\n",
    "## Features\n",
    "\n",
    "- **Vector-Based Recommendations**: Utilizes advanced vector search to find similar food items.\n",
    "- **Full-Text Search (FTS)**: Enables efficient searching of food items based on text descriptions.\n",
    "- **Hybrid Search**: Combines both vector search and full-text search for comprehensive results.\n",
    "- **Jina Reranker Model**: Improves search result accuracy by reranking models.\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "YWArkiYk0jHL"
   },
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "QrvjHAfb0jHL"
   },
   "source": [
    "### Install required dependencies"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "UNffzgyY0jHM",
    "outputId": "b9c63f58-c61f-4523-c633-ba6e99fb448e"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (2.2.2)\n",
      "Requirement already satisfied: numpy>=1.22.4 in /usr/local/lib/python3.10/dist-packages (from pandas) (1.26.4)\n",
      "Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas) (2.8.2)\n",
      "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas) (2024.2)\n",
      "Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.10/dist-packages (from pandas) (2024.2)\n",
      "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.2->pandas) (1.17.0)\n",
      "Collecting lancedb\n",
      "  Downloading lancedb-0.18.0-cp39-abi3-manylinux_2_28_x86_64.whl.metadata (4.0 kB)\n",
      "Collecting deprecation (from lancedb)\n",
      "  Downloading deprecation-2.1.0-py2.py3-none-any.whl.metadata (4.6 kB)\n",
      "Collecting pylance==0.22.0 (from lancedb)\n",
      "  Downloading pylance-0.22.0-cp39-abi3-manylinux_2_28_x86_64.whl.metadata (7.2 kB)\n",
      "Requirement already satisfied: tqdm>=4.27.0 in /usr/local/lib/python3.10/dist-packages (from lancedb) (4.67.1)\n",
      "Requirement already satisfied: pydantic>=1.10 in /usr/local/lib/python3.10/dist-packages (from lancedb) (2.10.4)\n",
      "Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from lancedb) (24.2)\n",
      "Collecting overrides>=0.7 (from lancedb)\n",
      "  Downloading overrides-7.7.0-py3-none-any.whl.metadata (5.8 kB)\n",
      "Requirement already satisfied: pyarrow>=14 in /usr/local/lib/python3.10/dist-packages (from pylance==0.22.0->lancedb) (17.0.0)\n",
      "Requirement already satisfied: numpy>=1.22 in /usr/local/lib/python3.10/dist-packages (from pylance==0.22.0->lancedb) (1.26.4)\n",
      "Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic>=1.10->lancedb) (0.7.0)\n",
      "Requirement already satisfied: pydantic-core==2.27.2 in /usr/local/lib/python3.10/dist-packages (from pydantic>=1.10->lancedb) (2.27.2)\n",
      "Requirement already satisfied: typing-extensions>=4.12.2 in /usr/local/lib/python3.10/dist-packages (from pydantic>=1.10->lancedb) (4.12.2)\n",
      "Downloading lancedb-0.18.0-cp39-abi3-manylinux_2_28_x86_64.whl (32.2 MB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m32.2/32.2 MB\u001b[0m \u001b[31m29.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hDownloading pylance-0.22.0-cp39-abi3-manylinux_2_28_x86_64.whl (38.3 MB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m38.3/38.3 MB\u001b[0m \u001b[31m16.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hDownloading overrides-7.7.0-py3-none-any.whl (17 kB)\n",
      "Downloading deprecation-2.1.0-py2.py3-none-any.whl (11 kB)\n",
      "Installing collected packages: overrides, deprecation, pylance, lancedb\n",
      "Successfully installed deprecation-2.1.0 lancedb-0.18.0 overrides-7.7.0 pylance-0.22.0\n"
     ]
    }
   ],
   "source": [
    "# install packages\n",
    "!pip install pandas\n",
    "!pip install lancedb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "oUjPxx272u-X",
    "outputId": "d45c2a95-38e6-493e-89e1-24a61318ddfb"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: tantivy in /usr/local/lib/python3.10/dist-packages (0.22.0)\n",
      "Collecting rerankers\n",
      "  Downloading rerankers-0.6.1-py3-none-any.whl.metadata (29 kB)\n",
      "Requirement already satisfied: pydantic in /usr/local/lib/python3.10/dist-packages (from rerankers) (2.10.4)\n",
      "Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from rerankers) (4.67.1)\n",
      "Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic->rerankers) (0.7.0)\n",
      "Requirement already satisfied: pydantic-core==2.27.2 in /usr/local/lib/python3.10/dist-packages (from pydantic->rerankers) (2.27.2)\n",
      "Requirement already satisfied: typing-extensions>=4.12.2 in /usr/local/lib/python3.10/dist-packages (from pydantic->rerankers) (4.12.2)\n",
      "Downloading rerankers-0.6.1-py3-none-any.whl (41 kB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m41.5/41.5 kB\u001b[0m \u001b[31m1.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hInstalling collected packages: rerankers\n",
      "Successfully installed rerankers-0.6.1\n"
     ]
    }
   ],
   "source": [
    "!pip install tantivy rerankers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "oeV7mp2R0jHN"
   },
   "source": [
    "### Download Data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "ZENpOEvS0jHN"
   },
   "source": [
    "For this notebook walkthrough, we will use food recommendation data from Kaggle. You can download the dataset from the following link:\n",
    "\n",
    "Download the food recommendation data from Kaggle\n",
    "\n",
    "https://www.kaggle.com/datasets/schemersays/food-recommendation-system"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "gWQI2h923JBJ"
   },
   "outputs": [],
   "source": [
    "# Download data\n",
    "!wget https://raw.githubusercontent.com/lancedb/vectordb-recipes/main/examples/archived_examples/Food_recommendation/main_food.csv\n",
    "!wget https://raw.githubusercontent.com/lancedb/vectordb-recipes/main/examples/archived_examples/Food_recommendation/ratings.csv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "id": "FGlscoxl0jHN"
   },
   "outputs": [],
   "source": [
    "# Loading and Merging Data into a Single File\n",
    "import pandas as pd\n",
    "\n",
    "df = pd.read_csv(\"main_food.csv\")\n",
    "df_rating = pd.read_csv(\"ratings.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "id": "rCjy46W00jHN"
   },
   "outputs": [],
   "source": [
    "main_df = pd.merge(df_rating, df, on=\"Food_ID\", how=\"inner\")\n",
    "main_df.to_csv(\"main_df.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "id": "zzFbt4g40jHO"
   },
   "outputs": [],
   "source": [
    "# Now, open the main file which contains both merged datasets.\n",
    "df = pd.read_csv(\"main_df.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 206
    },
    "id": "XiWQ-KYi0jHO",
    "outputId": "e1033c39-1672-45f6-d665-2a9efcda6a02"
   },
   "outputs": [
    {
     "data": {
      "application/vnd.google.colaboratory.intrinsic+json": {
       "summary": "{\n  \"name\": \"df\",\n  \"rows\": 511,\n  \"fields\": [\n    {\n      \"column\": \"Unnamed: 0\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 147,\n        \"min\": 0,\n        \"max\": 510,\n        \"num_unique_values\": 511,\n        \"samples\": [\n          124,\n          84,\n          433\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"User_ID\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 28.73921290350848,\n        \"min\": 1.0,\n        \"max\": 100.0,\n        \"num_unique_values\": 100,\n        \"samples\": [\n          84.0,\n          54.0,\n          71.0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Food_ID\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 91.29262932706344,\n        \"min\": 1.0,\n        \"max\": 309.0,\n        \"num_unique_values\": 309,\n        \"samples\": [\n          210.0,\n          110.0,\n          154.0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Rating\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 2.8662362487559436,\n        \"min\": 1.0,\n        \"max\": 10.0,\n        \"num_unique_values\": 10,\n        \"samples\": [\n          2.0,\n          3.0,\n          9.0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Name\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 309,\n        \"samples\": [\n          \"quinoa coconut crumble custard\",\n          \"chicken and mushroom lasagna\",\n          \"fish with white sauce\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"C_Type\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 11,\n        \"samples\": [\n          \"Beverage\",\n          \"Snack\",\n          \"Thai\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Veg_Non\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 2,\n        \"samples\": [\n          \"veg\",\n          \"non-veg\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Describe\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 306,\n        \"samples\": [\n          \"dahi, cumin powder, garlic paste, garam masala, turmeric powder, red chilli powder, salt, boneless chicken, oil, green chilli, onion, tomato\",\n          \"chicken, onion, green chilli, garlic, ginger, salt, aromatic powder, soya sauce, oyster sauce, spring onion, filo sheets\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    }\n  ]\n}",
       "type": "dataframe",
       "variable_name": "df"
      },
      "text/html": [
       "\n",
       "  <div id=\"df-1a4d08ad-05d2-482c-898f-1fce71344889\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>User_ID</th>\n",
       "      <th>Food_ID</th>\n",
       "      <th>Rating</th>\n",
       "      <th>Name</th>\n",
       "      <th>C_Type</th>\n",
       "      <th>Veg_Non</th>\n",
       "      <th>Describe</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>88.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>peri peri chicken satay</td>\n",
       "      <td>Snack</td>\n",
       "      <td>non-veg</td>\n",
       "      <td>boneless skinless chicken thigh (trimmed), sal...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>46.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>steam bunny chicken bao</td>\n",
       "      <td>Japanese</td>\n",
       "      <td>non-veg</td>\n",
       "      <td>buns, all purpose white flour, dry yeast, suga...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>1.0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>green lentil dessert fudge</td>\n",
       "      <td>Dessert</td>\n",
       "      <td>veg</td>\n",
       "      <td>whole moong beans, cow ghee, raisins, whole mi...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>1.0</td>\n",
       "      <td>25.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>cashew nut cookies</td>\n",
       "      <td>Dessert</td>\n",
       "      <td>veg</td>\n",
       "      <td>cashew paste, ghee, khaand (a sweetening agent...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>2.0</td>\n",
       "      <td>49.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>christmas tree pizza</td>\n",
       "      <td>Italian</td>\n",
       "      <td>veg</td>\n",
       "      <td>pizza dough (2 boules), red pepper, red onion,...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-1a4d08ad-05d2-482c-898f-1fce71344889')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-1a4d08ad-05d2-482c-898f-1fce71344889 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-1a4d08ad-05d2-482c-898f-1fce71344889');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-f1512f9c-5307-4473-b414-532b058d1dff\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-f1512f9c-5307-4473-b414-532b058d1dff')\"\n",
       "            title=\"Suggest charts\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-f1512f9c-5307-4473-b414-532b058d1dff button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "   Unnamed: 0  User_ID  Food_ID  Rating                        Name    C_Type  \\\n",
       "0           0      1.0     88.0     4.0     peri peri chicken satay     Snack   \n",
       "1           1      1.0     46.0     3.0     steam bunny chicken bao  Japanese   \n",
       "2           2      1.0     24.0     5.0  green lentil dessert fudge   Dessert   \n",
       "3           3      1.0     25.0     4.0          cashew nut cookies   Dessert   \n",
       "4           4      2.0     49.0     1.0        christmas tree pizza   Italian   \n",
       "\n",
       "   Veg_Non                                           Describe  \n",
       "0  non-veg  boneless skinless chicken thigh (trimmed), sal...  \n",
       "1  non-veg  buns, all purpose white flour, dry yeast, suga...  \n",
       "2      veg  whole moong beans, cow ghee, raisins, whole mi...  \n",
       "3      veg  cashew paste, ghee, khaand (a sweetening agent...  \n",
       "4      veg  pizza dough (2 boules), red pepper, red onion,...  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "tzhDVWuP0jHO"
   },
   "source": [
    "### Data Preprocessing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "id": "p41002yW0jHP"
   },
   "outputs": [],
   "source": [
    "# We are adding all important columns into the text column to enhance full-text search (FTS) and overall search performance.\n",
    "df[\"text\"] = df.apply(\n",
    "    lambda row: f\"{row['Name']} {row['C_Type']} {row['Veg_Non']}: {row['Describe']}\",\n",
    "    axis=1,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 54
    },
    "id": "ExJVsE-o0jHP",
    "outputId": "8d2b826e-214f-44cd-c9ac-2b8c0416b75c"
   },
   "outputs": [
    {
     "data": {
      "application/vnd.google.colaboratory.intrinsic+json": {
       "type": "string"
      },
      "text/plain": [
       "'peri peri chicken satay Snack non-veg: boneless skinless chicken thigh (trimmed), salt and pepper, yogurt, chilli powder, ginger garlic paste, coriander leaves, oil to fry, peri peri sauce, potato fries'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# just chcking our text data\n",
    "df[\"text\"][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 310
    },
    "id": "Gpbu9Cw60jHP",
    "outputId": "dd1e794c-1ec6-4fad-cf82-956fe9048076"
   },
   "outputs": [
    {
     "data": {
      "application/vnd.google.colaboratory.intrinsic+json": {
       "summary": "{\n  \"name\": \"df\",\n  \"rows\": 511,\n  \"fields\": [\n    {\n      \"column\": \"Unnamed: 0\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 147,\n        \"min\": 0,\n        \"max\": 510,\n        \"num_unique_values\": 511,\n        \"samples\": [\n          124,\n          84,\n          433\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"User_ID\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 28.73921290350848,\n        \"min\": 1.0,\n        \"max\": 100.0,\n        \"num_unique_values\": 100,\n        \"samples\": [\n          84.0,\n          54.0,\n          71.0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Food_ID\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 91.29262932706344,\n        \"min\": 1.0,\n        \"max\": 309.0,\n        \"num_unique_values\": 309,\n        \"samples\": [\n          210.0,\n          110.0,\n          154.0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Rating\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 2.8662362487559436,\n        \"min\": 1.0,\n        \"max\": 10.0,\n        \"num_unique_values\": 10,\n        \"samples\": [\n          2.0,\n          3.0,\n          9.0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Name\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 309,\n        \"samples\": [\n          \"quinoa coconut crumble custard\",\n          \"chicken and mushroom lasagna\",\n          \"fish with white sauce\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"C_Type\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 11,\n        \"samples\": [\n          \"Beverage\",\n          \"Snack\",\n          \"Thai\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Veg_Non\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 2,\n        \"samples\": [\n          \"veg\",\n          \"non-veg\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Describe\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 306,\n        \"samples\": [\n          \"dahi, cumin powder, garlic paste, garam masala, turmeric powder, red chilli powder, salt, boneless chicken, oil, green chilli, onion, tomato\",\n          \"chicken, onion, green chilli, garlic, ginger, salt, aromatic powder, soya sauce, oyster sauce, spring onion, filo sheets\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"text\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 309,\n        \"samples\": [\n          \"quinoa coconut crumble custard Dessert veg: Knoia (cooked), oats, cinnamon powder, salt, brown sugar or jaggery, nuts, coconut nuts, eggs, kinoia, coconut milk, maple syrup, vanilla extract, cinnamon powder, salt, honey\",\n          \"chicken and mushroom lasagna Italian non-veg: chicken, salt, crush black pepper, garlic cloves (minced), olive oil, fresh thyme, button mushroom, onion, low fat milk, basil, basil-tomato sauce\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    }\n  ]\n}",
       "type": "dataframe",
       "variable_name": "df"
      },
      "text/html": [
       "\n",
       "  <div id=\"df-65247628-9fde-4fc0-9a29-9b5d38fbda66\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>User_ID</th>\n",
       "      <th>Food_ID</th>\n",
       "      <th>Rating</th>\n",
       "      <th>Name</th>\n",
       "      <th>C_Type</th>\n",
       "      <th>Veg_Non</th>\n",
       "      <th>Describe</th>\n",
       "      <th>text</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>88.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>peri peri chicken satay</td>\n",
       "      <td>Snack</td>\n",
       "      <td>non-veg</td>\n",
       "      <td>boneless skinless chicken thigh (trimmed), sal...</td>\n",
       "      <td>peri peri chicken satay Snack non-veg: boneles...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>46.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>steam bunny chicken bao</td>\n",
       "      <td>Japanese</td>\n",
       "      <td>non-veg</td>\n",
       "      <td>buns, all purpose white flour, dry yeast, suga...</td>\n",
       "      <td>steam bunny chicken bao Japanese non-veg: buns...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>1.0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>green lentil dessert fudge</td>\n",
       "      <td>Dessert</td>\n",
       "      <td>veg</td>\n",
       "      <td>whole moong beans, cow ghee, raisins, whole mi...</td>\n",
       "      <td>green lentil dessert fudge Dessert veg: whole ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>1.0</td>\n",
       "      <td>25.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>cashew nut cookies</td>\n",
       "      <td>Dessert</td>\n",
       "      <td>veg</td>\n",
       "      <td>cashew paste, ghee, khaand (a sweetening agent...</td>\n",
       "      <td>cashew nut cookies Dessert veg: cashew paste, ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>2.0</td>\n",
       "      <td>49.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>christmas tree pizza</td>\n",
       "      <td>Italian</td>\n",
       "      <td>veg</td>\n",
       "      <td>pizza dough (2 boules), red pepper, red onion,...</td>\n",
       "      <td>christmas tree pizza Italian veg: pizza dough ...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-65247628-9fde-4fc0-9a29-9b5d38fbda66')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-65247628-9fde-4fc0-9a29-9b5d38fbda66 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-65247628-9fde-4fc0-9a29-9b5d38fbda66');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-c760caa6-ce45-4ce3-b828-a7dab6e59396\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-c760caa6-ce45-4ce3-b828-a7dab6e59396')\"\n",
       "            title=\"Suggest charts\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-c760caa6-ce45-4ce3-b828-a7dab6e59396 button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "   Unnamed: 0  User_ID  Food_ID  Rating                        Name    C_Type  \\\n",
       "0           0      1.0     88.0     4.0     peri peri chicken satay     Snack   \n",
       "1           1      1.0     46.0     3.0     steam bunny chicken bao  Japanese   \n",
       "2           2      1.0     24.0     5.0  green lentil dessert fudge   Dessert   \n",
       "3           3      1.0     25.0     4.0          cashew nut cookies   Dessert   \n",
       "4           4      2.0     49.0     1.0        christmas tree pizza   Italian   \n",
       "\n",
       "   Veg_Non                                           Describe  \\\n",
       "0  non-veg  boneless skinless chicken thigh (trimmed), sal...   \n",
       "1  non-veg  buns, all purpose white flour, dry yeast, suga...   \n",
       "2      veg  whole moong beans, cow ghee, raisins, whole mi...   \n",
       "3      veg  cashew paste, ghee, khaand (a sweetening agent...   \n",
       "4      veg  pizza dough (2 boules), red pepper, red onion,...   \n",
       "\n",
       "                                                text  \n",
       "0  peri peri chicken satay Snack non-veg: boneles...  \n",
       "1  steam bunny chicken bao Japanese non-veg: buns...  \n",
       "2  green lentil dessert fudge Dessert veg: whole ...  \n",
       "3  cashew nut cookies Dessert veg: cashew paste, ...  \n",
       "4  christmas tree pizza Italian veg: pizza dough ...  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "YaRgiOgw0jHP"
   },
   "source": [
    "\n",
    "\n",
    "To improve accuracy, we should include both numerical and string representations of ratings. First, add a new column, rating_str, containing the string values for each rating. Then, append both the numerical and string ratings to the text column. This approach increases the chances of achieving better accuracy.\n",
    "this kind of trick exp you need to do for improving your accuracy\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "id": "Qe95BUYu0jHP"
   },
   "outputs": [],
   "source": [
    "# Create a mapping from numbers to strings\n",
    "num_to_string = {\n",
    "    0.0: \"zero\",\n",
    "    1.0: \"one\",\n",
    "    2.0: \"two\",\n",
    "    3.0: \"three\",\n",
    "    4.0: \"four\",\n",
    "    5.0: \"five\",\n",
    "    6.0: \"six\",\n",
    "    7.0: \"seven\",\n",
    "    8.0: \"eight\",\n",
    "    9.0: \"nine\",\n",
    "    10.0: \"ten\",\n",
    "}\n",
    "# Replace numerical ratings with their string equivalents\n",
    "df[\"Rating_str\"] = df[\"Rating\"].map(num_to_string)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "id": "OOrYVHH70jHP"
   },
   "outputs": [],
   "source": [
    "df[\"Rating\"] = df[\"Rating\"].astype(int)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 310
    },
    "id": "ZpdL_9Ki0jHP",
    "outputId": "6892b5ee-e6ab-4ea3-a2c5-4c611ea97feb"
   },
   "outputs": [
    {
     "data": {
      "application/vnd.google.colaboratory.intrinsic+json": {
       "summary": "{\n  \"name\": \"df\",\n  \"rows\": 511,\n  \"fields\": [\n    {\n      \"column\": \"Unnamed: 0\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 147,\n        \"min\": 0,\n        \"max\": 510,\n        \"num_unique_values\": 511,\n        \"samples\": [\n          124,\n          84,\n          433\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"User_ID\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 28.73921290350848,\n        \"min\": 1.0,\n        \"max\": 100.0,\n        \"num_unique_values\": 100,\n        \"samples\": [\n          84.0,\n          54.0,\n          71.0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Food_ID\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 91.29262932706344,\n        \"min\": 1.0,\n        \"max\": 309.0,\n        \"num_unique_values\": 309,\n        \"samples\": [\n          210.0,\n          110.0,\n          154.0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Rating\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 2,\n        \"min\": 1,\n        \"max\": 10,\n        \"num_unique_values\": 10,\n        \"samples\": [\n          2,\n          3,\n          9\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Name\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 309,\n        \"samples\": [\n          \"quinoa coconut crumble custard\",\n          \"chicken and mushroom lasagna\",\n          \"fish with white sauce\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"C_Type\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 11,\n        \"samples\": [\n          \"Beverage\",\n          \"Snack\",\n          \"Thai\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Veg_Non\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 2,\n        \"samples\": [\n          \"veg\",\n          \"non-veg\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Describe\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 306,\n        \"samples\": [\n          \"dahi, cumin powder, garlic paste, garam masala, turmeric powder, red chilli powder, salt, boneless chicken, oil, green chilli, onion, tomato\",\n          \"chicken, onion, green chilli, garlic, ginger, salt, aromatic powder, soya sauce, oyster sauce, spring onion, filo sheets\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"text\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 309,\n        \"samples\": [\n          \"quinoa coconut crumble custard Dessert veg: Knoia (cooked), oats, cinnamon powder, salt, brown sugar or jaggery, nuts, coconut nuts, eggs, kinoia, coconut milk, maple syrup, vanilla extract, cinnamon powder, salt, honey\",\n          \"chicken and mushroom lasagna Italian non-veg: chicken, salt, crush black pepper, garlic cloves (minced), olive oil, fresh thyme, button mushroom, onion, low fat milk, basil, basil-tomato sauce\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Rating_str\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 10,\n        \"samples\": [\n          \"two\",\n          \"three\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    }\n  ]\n}",
       "type": "dataframe",
       "variable_name": "df"
      },
      "text/html": [
       "\n",
       "  <div id=\"df-7c9a863c-031e-4ebd-a344-88ac5c06a92f\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>User_ID</th>\n",
       "      <th>Food_ID</th>\n",
       "      <th>Rating</th>\n",
       "      <th>Name</th>\n",
       "      <th>C_Type</th>\n",
       "      <th>Veg_Non</th>\n",
       "      <th>Describe</th>\n",
       "      <th>text</th>\n",
       "      <th>Rating_str</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>88.0</td>\n",
       "      <td>4</td>\n",
       "      <td>peri peri chicken satay</td>\n",
       "      <td>Snack</td>\n",
       "      <td>non-veg</td>\n",
       "      <td>boneless skinless chicken thigh (trimmed), sal...</td>\n",
       "      <td>peri peri chicken satay Snack non-veg: boneles...</td>\n",
       "      <td>four</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>46.0</td>\n",
       "      <td>3</td>\n",
       "      <td>steam bunny chicken bao</td>\n",
       "      <td>Japanese</td>\n",
       "      <td>non-veg</td>\n",
       "      <td>buns, all purpose white flour, dry yeast, suga...</td>\n",
       "      <td>steam bunny chicken bao Japanese non-veg: buns...</td>\n",
       "      <td>three</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>1.0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>5</td>\n",
       "      <td>green lentil dessert fudge</td>\n",
       "      <td>Dessert</td>\n",
       "      <td>veg</td>\n",
       "      <td>whole moong beans, cow ghee, raisins, whole mi...</td>\n",
       "      <td>green lentil dessert fudge Dessert veg: whole ...</td>\n",
       "      <td>five</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>1.0</td>\n",
       "      <td>25.0</td>\n",
       "      <td>4</td>\n",
       "      <td>cashew nut cookies</td>\n",
       "      <td>Dessert</td>\n",
       "      <td>veg</td>\n",
       "      <td>cashew paste, ghee, khaand (a sweetening agent...</td>\n",
       "      <td>cashew nut cookies Dessert veg: cashew paste, ...</td>\n",
       "      <td>four</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>2.0</td>\n",
       "      <td>49.0</td>\n",
       "      <td>1</td>\n",
       "      <td>christmas tree pizza</td>\n",
       "      <td>Italian</td>\n",
       "      <td>veg</td>\n",
       "      <td>pizza dough (2 boules), red pepper, red onion,...</td>\n",
       "      <td>christmas tree pizza Italian veg: pizza dough ...</td>\n",
       "      <td>one</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-7c9a863c-031e-4ebd-a344-88ac5c06a92f')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-7c9a863c-031e-4ebd-a344-88ac5c06a92f button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-7c9a863c-031e-4ebd-a344-88ac5c06a92f');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-6ba37949-9f09-4976-a0a1-dc6c5de6feca\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-6ba37949-9f09-4976-a0a1-dc6c5de6feca')\"\n",
       "            title=\"Suggest charts\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-6ba37949-9f09-4976-a0a1-dc6c5de6feca button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "   Unnamed: 0  User_ID  Food_ID  Rating                        Name    C_Type  \\\n",
       "0           0      1.0     88.0       4     peri peri chicken satay     Snack   \n",
       "1           1      1.0     46.0       3     steam bunny chicken bao  Japanese   \n",
       "2           2      1.0     24.0       5  green lentil dessert fudge   Dessert   \n",
       "3           3      1.0     25.0       4          cashew nut cookies   Dessert   \n",
       "4           4      2.0     49.0       1        christmas tree pizza   Italian   \n",
       "\n",
       "   Veg_Non                                           Describe  \\\n",
       "0  non-veg  boneless skinless chicken thigh (trimmed), sal...   \n",
       "1  non-veg  buns, all purpose white flour, dry yeast, suga...   \n",
       "2      veg  whole moong beans, cow ghee, raisins, whole mi...   \n",
       "3      veg  cashew paste, ghee, khaand (a sweetening agent...   \n",
       "4      veg  pizza dough (2 boules), red pepper, red onion,...   \n",
       "\n",
       "                                                text Rating_str  \n",
       "0  peri peri chicken satay Snack non-veg: boneles...       four  \n",
       "1  steam bunny chicken bao Japanese non-veg: buns...      three  \n",
       "2  green lentil dessert fudge Dessert veg: whole ...       five  \n",
       "3  cashew nut cookies Dessert veg: cashew paste, ...       four  \n",
       "4  christmas tree pizza Italian veg: pizza dough ...        one  "
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "id": "KFL67joG0jHP"
   },
   "outputs": [],
   "source": [
    "df[\"text\"] = df.apply(\n",
    "    lambda row: f\"{row['text']} rating: {row['Rating']} {row['Rating_str']}\", axis=1\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 310
    },
    "id": "og--7JRE0jHP",
    "outputId": "38f3ef28-2bb3-43bc-a43f-de1e60f3d869"
   },
   "outputs": [
    {
     "data": {
      "application/vnd.google.colaboratory.intrinsic+json": {
       "summary": "{\n  \"name\": \"df\",\n  \"rows\": 511,\n  \"fields\": [\n    {\n      \"column\": \"Unnamed: 0\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 147,\n        \"min\": 0,\n        \"max\": 510,\n        \"num_unique_values\": 511,\n        \"samples\": [\n          124,\n          84,\n          433\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"User_ID\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 28.73921290350848,\n        \"min\": 1.0,\n        \"max\": 100.0,\n        \"num_unique_values\": 100,\n        \"samples\": [\n          84.0,\n          54.0,\n          71.0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Food_ID\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 91.29262932706344,\n        \"min\": 1.0,\n        \"max\": 309.0,\n        \"num_unique_values\": 309,\n        \"samples\": [\n          210.0,\n          110.0,\n          154.0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Rating\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 2,\n        \"min\": 1,\n        \"max\": 10,\n        \"num_unique_values\": 10,\n        \"samples\": [\n          2,\n          3,\n          9\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Name\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 309,\n        \"samples\": [\n          \"quinoa coconut crumble custard\",\n          \"chicken and mushroom lasagna\",\n          \"fish with white sauce\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"C_Type\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 11,\n        \"samples\": [\n          \"Beverage\",\n          \"Snack\",\n          \"Thai\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Veg_Non\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 2,\n        \"samples\": [\n          \"veg\",\n          \"non-veg\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Describe\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 306,\n        \"samples\": [\n          \"dahi, cumin powder, garlic paste, garam masala, turmeric powder, red chilli powder, salt, boneless chicken, oil, green chilli, onion, tomato\",\n          \"chicken, onion, green chilli, garlic, ginger, salt, aromatic powder, soya sauce, oyster sauce, spring onion, filo sheets\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"text\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 476,\n        \"samples\": [\n          \"egg and cheddar cheese sandwich Mexican non-veg: egg, salt, pepper, ham slices, basil leaves rating: 2 two\",\n          \"balti meat Mexican non-veg: refined oil, black cardamoms, green cardamoms, mace, clove, cinnamon stick, black pepper corn, ginger garlic paste, ginger, green chilies, mutton curry cut, brown onion paste, salt, kashmiri red chili powder, tomato puree, garam masala powder, coriander powder, cumin powder rating: 5 five\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Rating_str\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 10,\n        \"samples\": [\n          \"two\",\n          \"three\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    }\n  ]\n}",
       "type": "dataframe",
       "variable_name": "df"
      },
      "text/html": [
       "\n",
       "  <div id=\"df-cffd8ad9-aae0-4a42-a958-ba6c75f3c08c\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>User_ID</th>\n",
       "      <th>Food_ID</th>\n",
       "      <th>Rating</th>\n",
       "      <th>Name</th>\n",
       "      <th>C_Type</th>\n",
       "      <th>Veg_Non</th>\n",
       "      <th>Describe</th>\n",
       "      <th>text</th>\n",
       "      <th>Rating_str</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>88.0</td>\n",
       "      <td>4</td>\n",
       "      <td>peri peri chicken satay</td>\n",
       "      <td>Snack</td>\n",
       "      <td>non-veg</td>\n",
       "      <td>boneless skinless chicken thigh (trimmed), sal...</td>\n",
       "      <td>peri peri chicken satay Snack non-veg: boneles...</td>\n",
       "      <td>four</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>46.0</td>\n",
       "      <td>3</td>\n",
       "      <td>steam bunny chicken bao</td>\n",
       "      <td>Japanese</td>\n",
       "      <td>non-veg</td>\n",
       "      <td>buns, all purpose white flour, dry yeast, suga...</td>\n",
       "      <td>steam bunny chicken bao Japanese non-veg: buns...</td>\n",
       "      <td>three</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>1.0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>5</td>\n",
       "      <td>green lentil dessert fudge</td>\n",
       "      <td>Dessert</td>\n",
       "      <td>veg</td>\n",
       "      <td>whole moong beans, cow ghee, raisins, whole mi...</td>\n",
       "      <td>green lentil dessert fudge Dessert veg: whole ...</td>\n",
       "      <td>five</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>1.0</td>\n",
       "      <td>25.0</td>\n",
       "      <td>4</td>\n",
       "      <td>cashew nut cookies</td>\n",
       "      <td>Dessert</td>\n",
       "      <td>veg</td>\n",
       "      <td>cashew paste, ghee, khaand (a sweetening agent...</td>\n",
       "      <td>cashew nut cookies Dessert veg: cashew paste, ...</td>\n",
       "      <td>four</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>2.0</td>\n",
       "      <td>49.0</td>\n",
       "      <td>1</td>\n",
       "      <td>christmas tree pizza</td>\n",
       "      <td>Italian</td>\n",
       "      <td>veg</td>\n",
       "      <td>pizza dough (2 boules), red pepper, red onion,...</td>\n",
       "      <td>christmas tree pizza Italian veg: pizza dough ...</td>\n",
       "      <td>one</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-cffd8ad9-aae0-4a42-a958-ba6c75f3c08c')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-cffd8ad9-aae0-4a42-a958-ba6c75f3c08c button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-cffd8ad9-aae0-4a42-a958-ba6c75f3c08c');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-d1dacc2a-e5b0-482a-9dd7-861dc1b0939d\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-d1dacc2a-e5b0-482a-9dd7-861dc1b0939d')\"\n",
       "            title=\"Suggest charts\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-d1dacc2a-e5b0-482a-9dd7-861dc1b0939d button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "   Unnamed: 0  User_ID  Food_ID  Rating                        Name    C_Type  \\\n",
       "0           0      1.0     88.0       4     peri peri chicken satay     Snack   \n",
       "1           1      1.0     46.0       3     steam bunny chicken bao  Japanese   \n",
       "2           2      1.0     24.0       5  green lentil dessert fudge   Dessert   \n",
       "3           3      1.0     25.0       4          cashew nut cookies   Dessert   \n",
       "4           4      2.0     49.0       1        christmas tree pizza   Italian   \n",
       "\n",
       "   Veg_Non                                           Describe  \\\n",
       "0  non-veg  boneless skinless chicken thigh (trimmed), sal...   \n",
       "1  non-veg  buns, all purpose white flour, dry yeast, suga...   \n",
       "2      veg  whole moong beans, cow ghee, raisins, whole mi...   \n",
       "3      veg  cashew paste, ghee, khaand (a sweetening agent...   \n",
       "4      veg  pizza dough (2 boules), red pepper, red onion,...   \n",
       "\n",
       "                                                text Rating_str  \n",
       "0  peri peri chicken satay Snack non-veg: boneles...       four  \n",
       "1  steam bunny chicken bao Japanese non-veg: buns...      three  \n",
       "2  green lentil dessert fudge Dessert veg: whole ...       five  \n",
       "3  cashew nut cookies Dessert veg: cashew paste, ...       four  \n",
       "4  christmas tree pizza Italian veg: pizza dough ...        one  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "id": "vJw2H6IR0jHP"
   },
   "outputs": [],
   "source": [
    "df = df.drop([\"User_ID\", \"Describe\", \"Unnamed: 0\", \"Rating_str\"], axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 206
    },
    "id": "_nKH8yiS0jHQ",
    "outputId": "02e40010-65ac-4630-9895-760c73c8ff81"
   },
   "outputs": [
    {
     "data": {
      "application/vnd.google.colaboratory.intrinsic+json": {
       "summary": "{\n  \"name\": \"df\",\n  \"rows\": 511,\n  \"fields\": [\n    {\n      \"column\": \"Food_ID\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 91.29262932706344,\n        \"min\": 1.0,\n        \"max\": 309.0,\n        \"num_unique_values\": 309,\n        \"samples\": [\n          210.0,\n          110.0,\n          154.0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Rating\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 2,\n        \"min\": 1,\n        \"max\": 10,\n        \"num_unique_values\": 10,\n        \"samples\": [\n          2,\n          3,\n          9\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Name\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 309,\n        \"samples\": [\n          \"quinoa coconut crumble custard\",\n          \"chicken and mushroom lasagna\",\n          \"fish with white sauce\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"C_Type\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 11,\n        \"samples\": [\n          \"Beverage\",\n          \"Snack\",\n          \"Thai\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Veg_Non\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 2,\n        \"samples\": [\n          \"veg\",\n          \"non-veg\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"text\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 476,\n        \"samples\": [\n          \"egg and cheddar cheese sandwich Mexican non-veg: egg, salt, pepper, ham slices, basil leaves rating: 2 two\",\n          \"balti meat Mexican non-veg: refined oil, black cardamoms, green cardamoms, mace, clove, cinnamon stick, black pepper corn, ginger garlic paste, ginger, green chilies, mutton curry cut, brown onion paste, salt, kashmiri red chili powder, tomato puree, garam masala powder, coriander powder, cumin powder rating: 5 five\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    }\n  ]\n}",
       "type": "dataframe",
       "variable_name": "df"
      },
      "text/html": [
       "\n",
       "  <div id=\"df-0d742b1e-d028-4f9e-be44-58be9af13bac\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Food_ID</th>\n",
       "      <th>Rating</th>\n",
       "      <th>Name</th>\n",
       "      <th>C_Type</th>\n",
       "      <th>Veg_Non</th>\n",
       "      <th>text</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>88.0</td>\n",
       "      <td>4</td>\n",
       "      <td>peri peri chicken satay</td>\n",
       "      <td>Snack</td>\n",
       "      <td>non-veg</td>\n",
       "      <td>peri peri chicken satay Snack non-veg: boneles...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>46.0</td>\n",
       "      <td>3</td>\n",
       "      <td>steam bunny chicken bao</td>\n",
       "      <td>Japanese</td>\n",
       "      <td>non-veg</td>\n",
       "      <td>steam bunny chicken bao Japanese non-veg: buns...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>24.0</td>\n",
       "      <td>5</td>\n",
       "      <td>green lentil dessert fudge</td>\n",
       "      <td>Dessert</td>\n",
       "      <td>veg</td>\n",
       "      <td>green lentil dessert fudge Dessert veg: whole ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>25.0</td>\n",
       "      <td>4</td>\n",
       "      <td>cashew nut cookies</td>\n",
       "      <td>Dessert</td>\n",
       "      <td>veg</td>\n",
       "      <td>cashew nut cookies Dessert veg: cashew paste, ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>49.0</td>\n",
       "      <td>1</td>\n",
       "      <td>christmas tree pizza</td>\n",
       "      <td>Italian</td>\n",
       "      <td>veg</td>\n",
       "      <td>christmas tree pizza Italian veg: pizza dough ...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-0d742b1e-d028-4f9e-be44-58be9af13bac')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-0d742b1e-d028-4f9e-be44-58be9af13bac button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-0d742b1e-d028-4f9e-be44-58be9af13bac');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-0b560664-37b4-4f0d-a97b-2b9fb19a7db4\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-0b560664-37b4-4f0d-a97b-2b9fb19a7db4')\"\n",
       "            title=\"Suggest charts\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-0b560664-37b4-4f0d-a97b-2b9fb19a7db4 button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "   Food_ID  Rating                        Name    C_Type  Veg_Non  \\\n",
       "0     88.0       4     peri peri chicken satay     Snack  non-veg   \n",
       "1     46.0       3     steam bunny chicken bao  Japanese  non-veg   \n",
       "2     24.0       5  green lentil dessert fudge   Dessert      veg   \n",
       "3     25.0       4          cashew nut cookies   Dessert      veg   \n",
       "4     49.0       1        christmas tree pizza   Italian      veg   \n",
       "\n",
       "                                                text  \n",
       "0  peri peri chicken satay Snack non-veg: boneles...  \n",
       "1  steam bunny chicken bao Japanese non-veg: buns...  \n",
       "2  green lentil dessert fudge Dessert veg: whole ...  \n",
       "3  cashew nut cookies Dessert veg: cashew paste, ...  \n",
       "4  christmas tree pizza Italian veg: pizza dough ...  "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "id": "0WYyBCxO0jHQ"
   },
   "outputs": [],
   "source": [
    "# Saving our data\n",
    "df.to_csv(\"final_food_recom_data.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "id": "VPe57Cdi0jHQ"
   },
   "outputs": [],
   "source": [
    "# your openai api key for embedding model\n",
    "import os\n",
    "\n",
    "os.environ[\"OPENAI_API_KEY\"] = \"sk-proj-...\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 564,
     "referenced_widgets": [
      "5617a03f618a49efb8908f44b57afbc0",
      "dcfc290e92394b3da06e40f123f9a709",
      "7d817d9597ec4df38d6cf9c178ebc16a",
      "93d2c5708f82459a9d7a05572cb70a9a",
      "72de8d5ccbef4ff0a9ee81bb60c50f1f",
      "d2a6af0bb3d343bcb21495e434021aa5",
      "e64498dd07a54bb99948486823ade8c2",
      "388808de14d64303942fe90efcafacdd",
      "8568417b14b24ebda58c348389350a22",
      "ac8bce8a1c234c33b0354106de2ead2f",
      "51bbe2e653ae4950927023bf7a4e8042",
      "e0c8ea4ec1844377acbf319014da8687",
      "159e1a00f6c846a7b7a35902282320ac",
      "f721c2e5389a495b9547aad9f2ea76aa",
      "5afd1d45d8b24ac1a06252f167c0f88d",
      "952b6d7076fe444cabddcf6dfc6c7697",
      "2fbaca795fc24e3baafd01028a2b8986",
      "e4d47f5c89ef43128c948f0084ba5798",
      "52971bfe5f8e4280a22dd814999c27eb",
      "2ed79e95f7f44d73928d379de4b5e1e5",
      "33e193c74644441295c99d9018abe9f1",
      "ae3e9859738a4de98622a3b3b8ce7ac9",
      "36fa727aa62048c7915c8de34c088366",
      "7075eb30430742e0ac1f9c76359f40fe",
      "ae771d2fff5048f7a8d37aa19de411e8",
      "2c382893b9464bd884484bc262cdea73",
      "21aab2c82852484ea58455d1cf7e4122",
      "953c8404e8a74cc49c1d3d135f48da32",
      "e2f8969c6539412bb69015231b832e64",
      "e6728748eb5b4672b629edd0205c259b",
      "dda9c0032c1b4946902eeff5d8bb76b8",
      "412997ac3a4b4815933ef9195857dcf8",
      "f7d6657280fe492795ea11fc79814952",
      "ab63bfda6513499a9e71b161eb70b27f",
      "751501adf88c4106acf7c6eebe2a70f7",
      "979da24eabb74c98a6f0595988332e8a",
      "c5fe871c7c07405ca9b3e0811f3617db",
      "cc1038b3bc5e4be693dd9f005bd9ea20",
      "3b82f46a3483417393e4f82d25a81dfa",
      "ae6e2314867342ba9e97a62cb68d0f50",
      "d2b272ba8fcc4eeeac15b581efd961b2",
      "8ab35c240f2740468f678979038a3049",
      "0f76d6d9f35c4fd2b7469c5c83db3ff8",
      "9b72e7c5c8aa4347a4505926c1aad1e9",
      "baddae2826b34b4c9c217c0d51f406c2",
      "0a3ccc0df0af47078440367e03f55c70",
      "f1a38aa3d4e6497e9c8c2e0acd95df2c",
      "bc16c3b2cd44403d848c8027ce760e09",
      "0d7fab4c6a3c45ab96681e1e6039ee11",
      "a6f4872f1cf64130afdf158892431893",
      "f47877116de8448e934f30203153ca1c",
      "43412797c5fd4884b5f3f282d0d53223",
      "57987d85833b467aa567a7302e327408",
      "5013e74af88a468daac9801bb6dab438",
      "cf90e1e7f7d44002b8c0169ea7acbaa0",
      "7dbe2cbb8f8f417dbfeb3e23365f888a",
      "6bbdc3ced13f4ed0bdc82427c1149044",
      "6d88a569e9b64803a19dbfa6205779a4",
      "69364eb2855d4735a736cbb47d6de6bc",
      "8c5ab668e16946d898bd356c3cc9a431",
      "12c2fde4bc64423582bfcaee1f668721",
      "288ba00f9d684d5d99b740a945672582",
      "b9b5139683d14cbf9ccaf4c5d71f65c7",
      "4defb67a0d964fe5ac5af836d5301099",
      "29d2b10708d340a480d1c692fdee8f5f",
      "32a463a1967f4027bfdbf7ba8e44b99b"
     ]
    },
    "id": "0A70NyNi0jHQ",
    "outputId": "02c25ade-1eb9-4bd6-9d4c-819f3c72865c"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loading ColBERTRanker model colbert-ir/colbertv2.0 (this message can be suppressed by setting verbose=0)\n",
      "No device set\n",
      "Using device cpu\n",
      "No dtype set\n",
      "Using dtype torch.float32\n",
      "Loading model colbert-ir/colbertv2.0, this might take a while...\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "5617a03f618a49efb8908f44b57afbc0",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "tokenizer_config.json:   0%|          | 0.00/405 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "e0c8ea4ec1844377acbf319014da8687",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "vocab.txt:   0%|          | 0.00/232k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "36fa727aa62048c7915c8de34c088366",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "tokenizer.json:   0%|          | 0.00/466k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "ab63bfda6513499a9e71b161eb70b27f",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "special_tokens_map.json:   0%|          | 0.00/112 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "baddae2826b34b4c9c217c0d51f406c2",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "config.json:   0%|          | 0.00/743 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "7dbe2cbb8f8f417dbfeb3e23365f888a",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "model.safetensors:   0%|          | 0.00/438M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Linear Dim set to: 128 for downcasting\n"
     ]
    },
    {
     "data": {
      "application/vnd.google.colaboratory.intrinsic+json": {
       "summary": "{\n  \"name\": \"lance_reranker_fts\",\n  \"rows\": 4,\n  \"fields\": [\n    {\n      \"column\": \"text\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 4,\n        \"samples\": [\n          \"coffee marinated mutton chops Thai non-veg: mutton chops, espresso, honey, balsamic vinegar, rosemary, pink peppercorns (crushed), olive oil, salt rating: 6 six\",\n          \"thai lamb balls Thai non-veg: lamb (minced), couscous, scallion, garlic, egg, parsley, olive oil, mint, ao nori herb, salt, five spice, cinnamon powder rating: 6 six\",\n          \"chicken potli Chinese non-veg: chicken, onion, green chilli, garlic, ginger, salt, aromatic powder, soya sauce, oyster sauce, spring onion, filo sheets rating: 6 six\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Food_ID\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 4,\n        \"samples\": [\n          \"132\",\n          \"128\",\n          \"98\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Name\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 4,\n        \"samples\": [\n          \"coffee marinated mutton chops\",\n          \"thai lamb balls\",\n          \"chicken potli\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Rating\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 1,\n        \"samples\": [\n          \"6\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"C_Type\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 3,\n        \"samples\": [\n          \"Chinese\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"Veg_Non\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 1,\n        \"samples\": [\n          \"non-veg\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"vector\",\n      \"properties\": {\n        \"dtype\": \"object\",\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"_relevance_score\",\n      \"properties\": {\n        \"dtype\": \"float32\",\n        \"num_unique_values\": 4,\n        \"samples\": [\n          1.0464649200439453\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    }\n  ]\n}",
       "type": "dataframe",
       "variable_name": "lance_reranker_fts"
      },
      "text/html": [
       "\n",
       "  <div id=\"df-b710c51b-b501-48e1-a6c9-60b4d67b9d85\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>text</th>\n",
       "      <th>Food_ID</th>\n",
       "      <th>Name</th>\n",
       "      <th>Rating</th>\n",
       "      <th>C_Type</th>\n",
       "      <th>Veg_Non</th>\n",
       "      <th>vector</th>\n",
       "      <th>_relevance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>chicken potli Chinese non-veg: chicken, onion,...</td>\n",
       "      <td>98</td>\n",
       "      <td>chicken potli</td>\n",
       "      <td>6</td>\n",
       "      <td>Chinese</td>\n",
       "      <td>non-veg</td>\n",
       "      <td>[-0.04389097, 0.009811673, -0.026068995, 0.008...</td>\n",
       "      <td>1.053606</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>coffee marinated mutton chops Thai non-veg: mu...</td>\n",
       "      <td>132</td>\n",
       "      <td>coffee marinated mutton chops</td>\n",
       "      <td>6</td>\n",
       "      <td>Thai</td>\n",
       "      <td>non-veg</td>\n",
       "      <td>[-0.04389097, 0.009811673, -0.026068995, 0.008...</td>\n",
       "      <td>1.046465</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>malabari fish curry Indian non-veg: sear fish,...</td>\n",
       "      <td>136</td>\n",
       "      <td>malabari fish curry</td>\n",
       "      <td>6</td>\n",
       "      <td>Indian</td>\n",
       "      <td>non-veg</td>\n",
       "      <td>[-0.04389097, 0.009811673, -0.026068995, 0.008...</td>\n",
       "      <td>1.000582</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>thai lamb balls Thai non-veg: lamb (minced), c...</td>\n",
       "      <td>128</td>\n",
       "      <td>thai lamb balls</td>\n",
       "      <td>6</td>\n",
       "      <td>Thai</td>\n",
       "      <td>non-veg</td>\n",
       "      <td>[-0.04389097, 0.009811673, -0.026068995, 0.008...</td>\n",
       "      <td>0.973492</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-b710c51b-b501-48e1-a6c9-60b4d67b9d85')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-b710c51b-b501-48e1-a6c9-60b4d67b9d85 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-b710c51b-b501-48e1-a6c9-60b4d67b9d85');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-7dd72fc6-96b9-42c6-99b1-b4d53d2d5e93\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-7dd72fc6-96b9-42c6-99b1-b4d53d2d5e93')\"\n",
       "            title=\"Suggest charts\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-7dd72fc6-96b9-42c6-99b1-b4d53d2d5e93 button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "\n",
       "  <div id=\"id_c5c421c0-bc32-4869-82b8-324a5fc33714\">\n",
       "    <style>\n",
       "      .colab-df-generate {\n",
       "        background-color: #E8F0FE;\n",
       "        border: none;\n",
       "        border-radius: 50%;\n",
       "        cursor: pointer;\n",
       "        display: none;\n",
       "        fill: #1967D2;\n",
       "        height: 32px;\n",
       "        padding: 0 0 0 0;\n",
       "        width: 32px;\n",
       "      }\n",
       "\n",
       "      .colab-df-generate:hover {\n",
       "        background-color: #E2EBFA;\n",
       "        box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "        fill: #174EA6;\n",
       "      }\n",
       "\n",
       "      [theme=dark] .colab-df-generate {\n",
       "        background-color: #3B4455;\n",
       "        fill: #D2E3FC;\n",
       "      }\n",
       "\n",
       "      [theme=dark] .colab-df-generate:hover {\n",
       "        background-color: #434B5C;\n",
       "        box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "        filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "        fill: #FFFFFF;\n",
       "      }\n",
       "    </style>\n",
       "    <button class=\"colab-df-generate\" onclick=\"generateWithVariable('lance_reranker_fts')\"\n",
       "            title=\"Generate code using this dataframe.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "       width=\"24px\">\n",
       "    <path d=\"M7,19H8.4L18.45,9,17,7.55,7,17.6ZM5,21V16.75L18.45,3.32a2,2,0,0,1,2.83,0l1.4,1.43a1.91,1.91,0,0,1,.58,1.4,1.91,1.91,0,0,1-.58,1.4L9.25,21ZM18.45,9,17,7.55Zm-12,3A5.31,5.31,0,0,0,4.9,8.1,5.31,5.31,0,0,0,1,6.5,5.31,5.31,0,0,0,4.9,4.9,5.31,5.31,0,0,0,6.5,1,5.31,5.31,0,0,0,8.1,4.9,5.31,5.31,0,0,0,12,6.5,5.46,5.46,0,0,0,6.5,12Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "    <script>\n",
       "      (() => {\n",
       "      const buttonEl =\n",
       "        document.querySelector('#id_c5c421c0-bc32-4869-82b8-324a5fc33714 button.colab-df-generate');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      buttonEl.onclick = () => {\n",
       "        google.colab.notebook.generateWithVariable('lance_reranker_fts');\n",
       "      }\n",
       "      })();\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                                                text Food_ID  \\\n",
       "0  chicken potli Chinese non-veg: chicken, onion,...      98   \n",
       "1  coffee marinated mutton chops Thai non-veg: mu...     132   \n",
       "2  malabari fish curry Indian non-veg: sear fish,...     136   \n",
       "3  thai lamb balls Thai non-veg: lamb (minced), c...     128   \n",
       "\n",
       "                            Name Rating   C_Type  Veg_Non  \\\n",
       "0                  chicken potli      6  Chinese  non-veg   \n",
       "1  coffee marinated mutton chops      6     Thai  non-veg   \n",
       "2            malabari fish curry      6   Indian  non-veg   \n",
       "3                thai lamb balls      6     Thai  non-veg   \n",
       "\n",
       "                                              vector  _relevance_score  \n",
       "0  [-0.04389097, 0.009811673, -0.026068995, 0.008...          1.053606  \n",
       "1  [-0.04389097, 0.009811673, -0.026068995, 0.008...          1.046465  \n",
       "2  [-0.04389097, 0.009811673, -0.026068995, 0.008...          1.000582  \n",
       "3  [-0.04389097, 0.009811673, -0.026068995, 0.008...          0.973492  "
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "import lancedb\n",
    "from lancedb.embeddings import EmbeddingFunctionRegistry, get_registry\n",
    "from lancedb.pydantic import LanceModel, Vector\n",
    "from lancedb.rerankers import (\n",
    "    ColbertReranker,\n",
    "    JinaReranker,\n",
    "    CohereReranker,\n",
    "    LinearCombinationReranker,\n",
    ")\n",
    "\n",
    "\n",
    "db = lancedb.connect(\"/tmp/foods\")\n",
    "\n",
    "# HF sentence transformer embeddings\n",
    "registry = EmbeddingFunctionRegistry.get_instance()\n",
    "func = registry.get(\"sentence-transformers\").create(device=\"cpu\")\n",
    "\n",
    "# uncomment below things for openai embeddings\n",
    "# openai embeddings\n",
    "# func = get_registry().get(\"openai\").create(name=\"text-embedding-ada-002\")\n",
    "\n",
    "\n",
    "class Words(LanceModel):\n",
    "    text: str = func.SourceField()  # Text column is combinations of all columns\n",
    "    Food_ID: str = func.SourceField()  # food id is food store name\n",
    "    Name: str = func.SourceField()  # Name of menu\n",
    "    Rating: str = func.SourceField()  # Rating given by users\n",
    "    C_Type: str = func.SourceField()  # category type of food\n",
    "    Veg_Non: str = func.SourceField()  # type of food its veg or non-veg\n",
    "    vector: Vector(func.ndims()) = func.VectorField()\n",
    "\n",
    "\n",
    "table = db.create_table(\"food_recommandations\", schema=Words, mode=\"overwrite\")\n",
    "table.add(data=df)\n",
    "\n",
    "# Full text search support\n",
    "table.create_fts_index(\"text\", replace=True)\n",
    "\n",
    "# check our guidance for othe for reranker  models https://lancedb.github.io/lancedb/reranking/\n",
    "# reranker = JinaReranker(api_key=\"key\")\n",
    "reranker = ColbertReranker()\n",
    "\n",
    "query = \" 6 rating non-veg meal \"\n",
    "\n",
    "# lance_reranker_hybrid = table.search(query, query_type=\"hybrid\").rerank(reranker=reranker).limit(5).to_pandas()    # use Hybrid search also\n",
    "lance_reranker_fts = (\n",
    "    table.search(query, query_type=\"fts\").rerank(reranker=reranker).limit(4).to_pandas()\n",
    ")\n",
    "\n",
    "lance_reranker_fts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "fAGmRvYb0jHQ",
    "outputId": "90e975ed-7f52-426e-cb47-26245d415c74"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  Food_ID                      Name        C_Type Veg_Non Rating\n",
      "0     303                  red rice  Healthy Food     veg      6\n",
      "1      10  broccoli and almond soup  Healthy Food     veg      6\n",
      "2      10  broccoli and almond soup  Healthy Food     veg      6\n",
      "3      36     spicy watermelon soup  Healthy Food     veg      6\n"
     ]
    }
   ],
   "source": [
    "# recommendations\n",
    "def get_recommendations(query):\n",
    "    results = (\n",
    "        table.search(query, query_type=\"fts\")\n",
    "        .rerank(reranker=reranker)\n",
    "        .limit(4)\n",
    "        .to_pandas()\n",
    "    )\n",
    "    return results[[\"Food_ID\", \"Name\", \"C_Type\", \"Veg_Non\", \"Rating\"]]\n",
    "\n",
    "\n",
    "# Example usage\n",
    "query = \"give me rating 6 non-veg food \"\n",
    "recommendations = get_recommendations(query)\n",
    "print(recommendations)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "6nfC8__40jHQ",
    "outputId": "c7e042ab-2b03-4616-c034-931b1ab33146"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  Food_ID                                      Name        C_Type  Veg_Non  \\\n",
      "0      87  roasted spring chicken with root veggies  Healthy Food  non-veg   \n",
      "1     247                   microwave chicken steak  Healthy Food  non-veg   \n",
      "2      86         roast turkey with cranberry sauce  Healthy Food  non-veg   \n",
      "3      86         roast turkey with cranberry sauce  Healthy Food  non-veg   \n",
      "\n",
      "  Rating  \n",
      "0      8  \n",
      "1      5  \n",
      "2      4  \n",
      "3      4  \n"
     ]
    }
   ],
   "source": [
    "# Example usage\n",
    "query = \"Non veg food near me \"\n",
    "recommendations = get_recommendations(query)\n",
    "print(recommendations)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "RthlD1oN0jHQ",
    "outputId": "7505e8a8-8501-4226-9dad-2a6d68ffa9e4"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  Food_ID                          Name    C_Type  Veg_Non Rating\n",
      "0     292                 chicken tikka    Indian  non-veg      8\n",
      "1      69  banana and maple ice lollies   Dessert      veg      8\n",
      "2     232         apple and walnut cake   Dessert      veg      8\n",
      "3      81             fruit infused tea  Beverage      veg      8\n"
     ]
    }
   ],
   "source": [
    "query = \" rating 8 \"\n",
    "recommendations = get_recommendations(query)\n",
    "print(recommendations)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "ztmZTBHx0jHQ",
    "outputId": "daed433f-eaf3-4b20-b503-50cb5f9bd18f"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  Food_ID                                               Name   C_Type  \\\n",
      "0     142  fish skewers with coriander and red wine vineg...     Thai   \n",
      "1     185                red wine braised mushroom flatbread  Italian   \n",
      "2      85  garlic and pinenut soup with burnt butter essence   French   \n",
      "3      85  garlic and pinenut soup with burnt butter essence   French   \n",
      "\n",
      "   Veg_Non Rating  \n",
      "0  non-veg      6  \n",
      "1      veg      7  \n",
      "2      veg      3  \n",
      "3      veg     10  \n"
     ]
    }
   ],
   "source": [
    "query = \"red wine with chicken\"\n",
    "recommendations = get_recommendations(query)\n",
    "print(recommendations)\n",
    "# here we have only one non veg with rating 9 so getting"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "uxs1K-7G0jHQ",
    "outputId": "ae252eff-da5d-4ca3-9b22-270926cd868b"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  Food_ID                                               Name        C_Type  \\\n",
      "0     303                                           red rice  Healthy Food   \n",
      "1      10                           broccoli and almond soup  Healthy Food   \n",
      "2      36                              spicy watermelon soup  Healthy Food   \n",
      "3     221  amaranthus granola with lemon yogurt, berries ...  Healthy Food   \n",
      "\n",
      "  Veg_Non Rating  \n",
      "0     veg      6  \n",
      "1     veg      6  \n",
      "2     veg      6  \n",
      "3     veg      6  \n"
     ]
    }
   ],
   "source": [
    "query = \"veg food with rating 6\"\n",
    "recommendations = get_recommendations(query)\n",
    "print(recommendations)\n",
    "# here we have only one non veg with rating 9 so getting"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "dV36C2-T0jHQ",
    "outputId": "45e58d29-fa6c-4189-ec6f-52c70582471e"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  Food_ID                     Name        C_Type Veg_Non Rating\n",
      "0     270  jalapeno cheese fingers       Mexican     veg      3\n",
      "1     270  jalapeno cheese fingers       Mexican     veg      5\n",
      "2     301               brown rice  Healthy Food     veg      1\n",
      "3     300               black rice  Healthy Food     veg      9\n"
     ]
    }
   ],
   "source": [
    "query = \" veg  food menu only\"\n",
    "recommendations = get_recommendations(query)\n",
    "print(recommendations)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "EPv5ww2t0jHR",
    "outputId": "ca0afb2c-91f3-4949-9816-21897da9b0f1"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  Food_ID                            Name    C_Type  Veg_Non Rating\n",
      "0      93  buldak (hot and spicy chicken)  Japanese  non-veg      7\n",
      "1     100             spicy chicken curry    Indian  non-veg      3\n",
      "2     100             spicy chicken curry    Indian  non-veg      4\n",
      "3     100             spicy chicken curry    Indian  non-veg      1\n"
     ]
    }
   ],
   "source": [
    "# Example usage\n",
    "query = \"rice with chicken spicy  \"\n",
    "recommendations = get_recommendations(query)\n",
    "print(recommendations)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "_VocfLe30jHR",
    "outputId": "77eeef96-24f8-4612-f3ad-00a7c6080ddf"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  Food_ID           Name    C_Type Veg_Non Rating\n",
      "0      83  spiced coffee  Beverage     veg      9\n",
      "1      84  filter coffee  Beverage     veg     10\n",
      "2      84  filter coffee  Beverage     veg     10\n",
      "3      84  filter coffee  Beverage     veg      2\n"
     ]
    }
   ],
   "source": [
    "# Example usage\n",
    "query = \"coffee \"\n",
    "recommendations = get_recommendations(query)\n",
    "print(recommendations)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "fJ76-Qen0jHR",
    "outputId": "6df1ed2f-65c3-4e2e-ef6e-e670c0e13afb"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  Food_ID                           Name        C_Type  Veg_Non Rating\n",
      "0     162              prawn potato soup          Thai      veg      9\n",
      "1      79  beetroot and green apple soup  Healthy Food      veg      1\n",
      "2     302                 koldil chicken       Chinese  non-veg      5\n",
      "3     298                     chicken 65       Chinese  non-veg      4\n"
     ]
    }
   ],
   "source": [
    "# Example usage\n",
    "query = \"soup chinese please\"\n",
    "recommendations = get_recommendations(query)\n",
    "print(recommendations)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "BiUusCHU0jHR"
   },
   "source": [
    "\n",
    "---\n",
    "\n",
    "Due to limited data, there may be instances where mixed results are returned, especially with a recommendation limit set to 4. The key to achieving better results lies in how you prepare your text data and optimize various hyperparameters, such as query types (hybrid, FTS, vector search). Additionally, experiment with different reranker methods. For further improvements, refer to our vector recipe repository for enhancing RAG methods and consult the LanceDB documentation for more details.\n",
    "docs: https://lancedb.github.io/lancedb/search/\n",
    "more such genai projects:https://github.com/lancedb/vectordb-recipes\n",
    "\n",
    "---"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "provenance": []
  },
  "kernelspec": {
   "display_name": "qdrant_music",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
